import 'package:flutter/services.dart';

class EventChannelToken {
  static EventChannelToken? _instance;

  static EventChannelToken getInstance() {
    if (null == _instance) _instance = EventChannelToken();
    return _instance!;
  }

  void Function(String token)? onDeviceToken;

  addListener({required Function(String token) onDeviceToken}) {
    EventChannel('PushApi/registerId').receiveBroadcastStream().listen((token) {
      print(token);
      onDeviceToken.call(token);
    });
  }
}
